<template>
  <div class="search-box">
    <div class="allSelect">
      <select v-model="value" @change="changeinfor" class="selectbtn">
        <option 
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
          @click="lookfor"></option>
      </select>
    </div>
    <div class="searchBody">
      <input type="text" class="searchBox" placeholder="搜索" v-model.trim="searchVal" @keyup="showkey($event)">
      <button class="searchBtn" @click="searchReault">搜索</button>
      <img src="../../assets/img/college/images/searchicon_06.png" alt="" class="searchImg">
    </div>
  </div>

</template>

<script>
  export default {
    data() {
      return {
        options: [
          {
          value: '2',
          label: '全部'
          },{
          value: '1',
          label: '视频'
          }, {
          value: '0',
          label: '图文'
        }],
        value: 2,
        list:[],
        searchVal:'',
        page:1,
        goodsList:[],
      }
    },
    created(){
      if(localStorage.getItem('getvalue')){
          this.value = localStorage.getItem('getvalue')
      }
    },
    methods:{
      lookfor(){
        this.$emit("childByValue",this.options);
      },
      changeinfor(){
        this.searchReault();
      },
      // 点击搜索
      searchReault:function () {

        if(localStorage.getItem('seachkey')){
            this.searchVal = localStorage.getItem('seachkey')
        }
        
        if(localStorage.getItem('changepage')){
            this.page = localStorage.getItem('changepage')
        }
       
        this.https("master/getObtainInformationList",{type:this.value,page:this.page,search:this.searchVal}).then(data => {
          this.list=data.data;
          this.listinfo = data
           localStorage.setItem('seachkey', this.searchVal)
           localStorage.setItem('changepage', this.page)
           localStorage.setItem('getvalue', this.value)
          this.$emit("typeByValue",this.value); 
          this.$emit("resultdata",this.list);
          this.$emit("resultdatainfo",this.listinfo);
        }); 
       },
       showkey(ev){
            if(ev.keyCode==13){
                this.searchReault();
            }
        },
    }
  }
</script>
<style>
    .selectbtn{
      width: 0.54rem;
      height: 0.25rem;
      background-color: #ffffff;
      border: 0.01rem solid #DDDDDD;
      cursor: pointer;
    }
    .search-box select {  
      border: solid 1px #dddddd;
      appearance:none;   
      background: url("../../assets/img//plan/images/selectbtn_03.png") no-repeat scroll center transparent; 
      background-position: 0.35rem;
      padding:0 0.03rem;  
    }  
    .tablelist{
      width: 2.01rem;
      height: auto;
      background: #ffffff;
      border: 0.01rem solid #DDDDDD !important;
      padding: 0.05rem 0.15rem !important;
    }
    .tablelist td{
      width: 2.01rem;
      height: 0.25rem;
      border: 0.01rem solid #DDDDDD;
      text-align: left !important;
      font-size: 0.12rem;
      color: #999999;
    }
</style>
<style scoped>
  @import url(../../assets/css/college/searchbtn.less);
</style>

